<?php
  /*
  * 商家进件回调
  */


class efenter_notifyControl extends SystemControl{


    public function __construct(){
        parent::__construct();
       // Language::read('member');
    }

    public  function indexOp(){

        $prefix = BASE_DATA_PATH."/vendors/weixin";
        include_once($prefix."/log_.php");
        //$json = $GLOBALS['HTTP_RAW_POST_DATA'];
        //$data = json_decode($json, true);
        $time = date('Y-m-d', time());
        $log_ = new Log_();
        $log_name = BASE_DATA_PATH."/log/yifujj/" . $time . ".log";
        if(!file_exists($log_name)){
             $fp=fopen("$log_name", "w+");
        }
        //$log_->log_result($log_name, "【接收到的notify通知】:\n".$json."\n");
        //$log_->log_result($log_name, "【接收到的notify通知】:\n".$_POST."\n");

        $log_->log_result($log_name, "【接收到的POST通知】:\n".json_encode($_POST)."\n");

        $model = Model('member_merchant');
        if(!empty($_POST['mch_id'])){
            $merchantinfo = $model->getMerchantInfo(array('submch_id'=>$_POST['mch_id']),'merchant_id');
            if(!empty($merchantinfo) && is_array($merchantinfo)){
                if($_POST['status'] =='1'){
                    $log_->log_result($log_name, "【银行审核未通过】:\n".$_POST['comment']."\n");
                    $re = $model->updateMerchant(array('merchant_id'=>$merchantinfo['merchant_id']),array('bank_status'=>30,'not_passcause'=>$_POST['comment']));
                    $re && exit('00000000');
                }else{
                    $res = $model->updateMerchant(array('merchant_id'=>$merchantinfo['merchant_id']),array('bank_status'=>20));
                    $res && exit('00000000');
                }
            }else{
                $log_->log_result($log_name, "【商户不存在】:\n".json_encode($_POST)."\n");
            }


        }




    }
}


